home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / DTS Japan-Sample Code / QuickTime•MacApp2.0•6.0.7 / UDemoText.cp < prev    next >
Encoding:
Text File  |  1992-02-05  |  34.6 KB  |  1,100 lines  |  [TEXT/MPS ]

  1. // Copyright © 1991 by Taro Tanaka, Japan DTS, Apple Computer Japan, Inc. All rights reserved.
  2.  
  3. // Copyright © 1989-1990 by Apple Computer, Inc.  All rights reserved. 
  4.  
  5.  
  6. #ifndef __UDEMOTEXT__
  7. #include "UDemoText.h"
  8. #endif
  9.  
  10. extern "C" char* memcpy(void*, void*, int);
  11. #define pstrcpy(p,q) memcpy(p, q, q[0]+1)                    // added for translation: Pascal strcpy
  12. extern "C" void printf(const char *, ...);
  13.  
  14.     // Menu numbers 
  15. const short mFont                        = 10;
  16.  
  17.     // Command numbers 
  18.  
  19. const short cWidthFrame                 = 601;                // View-width-determination commands
  20. const short cWidthView                    = 602;
  21. const short cWidthOnePage                = 603;
  22.  
  23. const short cHeightFrame                = 604;                // View-height-determination commands
  24. const short cHeightPages                = 605;
  25. const short cHeightText                 = 606;
  26. const short cHeightConst                = 607;
  27.  
  28. const short cJustLeft                    = 608;                // Justification commands
  29. const short cJustCenter                 = 609;
  30. const short cJustRight                    = 610;
  31.  
  32.   /*
  33.  Command numbering scheme:
  34. const short styles = 1000
  35. const short sizes = 1100
  36. const short just = 1200
  37. const short fonts = 1300
  38. const short hiers = 1400
  39. const short colors = 1500
  40.   */
  41.  
  42.     // Command numbers for typestyle attributes
  43. const short cPlainText                    = 1001;
  44. const short cBold                        = 1002;
  45. const short cItalic                     = 1003;
  46. const short cUnderline                    = 1004;
  47. const short cOutline                    = 1005;
  48. const short cShadow                     = 1006;
  49. const short cCondense                    = 1007;
  50. const short cExtend                     = 1008;
  51.  
  52.     // Command numbers for font-size commands
  53. const short cSizeChange                 = 1100;
  54. const short cSizeBase                    = 1100;
  55. const short cSizeMin                    = 1109;
  56. const short cSizeMax                    = 1124;
  57.     // 1101-1197 reserved for font sizes 1-97 pts.
  58. const short cSizeGrow                    = 1198;
  59. const short cSizeShrink                 = 1199;
  60.  
  61.     // Command numbers to cover other stylistic changes
  62. const short cJustChange                 = 1200;
  63. const short cFontChange                 = 1300;
  64.  
  65.     // Command numbers for the hierarchial menu
  66. const short cStyle                        = 1401;
  67. const short cSize                        = 1402;
  68. const short cFont                        = 1403;
  69. const short cColor                        = 1404;
  70.  
  71.     // Command numbers for changing colors
  72. const short cColorChange                = 1500;
  73. const short cColorText                    = 1501;
  74. const short cColorBackground            = 1502;
  75.  
  76. const short cXShowBreaks                = 1601;
  77.  
  78.     // Constant for staggering windows
  79. const short kStaggerAmount                = 16;
  80.  
  81.     // Constant for amount to relative size text selection
  82. const short kRelSizeAmount                = 4;
  83.  
  84.     // Constants for the text specs resource
  85. const unsigned long kTextSpecsRsrcType    = 'SPEC';
  86. const short kTextSpecsRsrcID            = 1;
  87.  
  88.     // Constants for the text style resource
  89. const unsigned long kTextStyleRsrcType    = 'STYL';
  90. const short kStylesRsrcID                = 1;
  91. const short kElementsRsrcID             = 2;
  92.  
  93.     // Constants for the print info resource
  94. const unsigned long kPrintInfoRsrcType    = 'PRNT';
  95. const short kPrintInfoRsrcID            = 1;
  96.  
  97.     // Constants for the prompts string list
  98. const short kPromptsRsrcID                = 1001;
  99. const short kColTextPrompt                = 1;
  100. const short kColBackPrompt                = 2;
  101.  
  102.     // The 'File is too large' alert
  103. const short kFileTooBig                 = 1000;
  104.  
  105. const short kHierDisplayedMBar            = 131;            // Displayed menus on hier. menu system
  106. const short kNonHierDisplayedMBar         = 128;            // Displayed menus on non-hier. system
  107.  
  108. const short kHierMenuOffset             = 1000;         // Offset added to non-hier menu cmds to get
  109.                                                         //  right #
  110.                                                         
  111. const short kMovieFrameOffset            = 4;
  112. const short kMovieControllerHeight        = 16;
  113.  
  114. const unsigned long kDemoTextSignature    = 'yuki';
  115.  
  116. TextSpecs    gDefaultSpecs;                                // Text specs as default for new documents
  117. short        gStaggerCount;
  118. short        gMenuOfs;
  119. Str255        gPromptString;
  120.  
  121. extern TDemoTextApplication *gDemoTextApplication;
  122.  
  123.  
  124. //--------------------------------------------------------------------------------------------------
  125. #pragma segment ARes
  126.  
  127. StringPtr GetPrompt(short index)
  128. {
  129.     GetIndString(gPromptString, kPromptsRsrcID, index);
  130.     return (StringPtr) &gPromptString;
  131. }
  132.  
  133. //******************************************************************************************
  134. //  T D e m o T e x t A p p l i c a t i o n
  135. //******************************************************************************************
  136. //--------------------------------------------------------------------------------------------------
  137. #pragma segment AInit
  138.  
  139. pascal void TDemoTextApplication::IDemoTextApplication()
  140. {
  141.     
  142.     Str255    fontName;
  143.     TTEView    *aTEView;
  144.  
  145. #if qNeedsHierarchialMenus == 0
  146.     if (! gConfiguration.hasHierarchicalMenus) {
  147.         gMBarDisplayed = kNonHierDisplayedMBar;
  148.         gMenuOfs = 0;
  149.     } else
  150. #endif
  151.     {
  152.         gMBarDisplayed = kHierDisplayedMBar;
  153.         gMenuOfs = kHierMenuOffset;
  154.     }
  155.  
  156.     IApplication(kFileType);
  157.  
  158.     if (! gFinderPrinting) {
  159.         AddResMenu(GetMHandle(mFont), 'FONT');
  160.  
  161.         gStaggerCount = 0;
  162.  
  163.         SetStyle(cBold, bold);
  164.         SetStyle(cUnderline, underline);
  165.         SetStyle(cItalic, italic);
  166.         SetStyle(cOutline, outline);
  167.         SetStyle(cShadow, shadow);
  168.         SetStyle(cCondense, condense);
  169.         SetStyle(cExtend, extend);
  170.     }
  171.  
  172.     // Instead of hard-wiring a default text style, get it from the TEView resource by
  173.     if (gDeadStripSuppression) {
  174.         TMovieView *aMovieView = new TMovieView;
  175.     }
  176.  
  177.     aTEView = (TTEView*) DoCreateViews(NULL, NULL, kViewRsrcID, &gZeroVPt);
  178.     FailNIL(aTEView);
  179.     GetFontName(aTEView->fTextStyle.tsFont, fontName);
  180.     //gDefaultSpecs.theTextFont = fontName;                        // Set up initial text specs
  181.     pstrcpy(gDefaultSpecs.theTextFont, fontName);                // Kludged Pascal string copy
  182.     gDefaultSpecs.theTextFace = aTEView->fTextStyle.tsFace;
  183.     gDefaultSpecs.theTextSize = aTEView->fTextStyle.tsSize;
  184.     gDefaultSpecs.theTextColor = aTEView->fTextStyle.tsColor;
  185.     gDefaultSpecs.theJustification = aTEView->fJustification;
  186.     gDefaultSpecs.theBackColor = gRGBWhite;
  187.     aTEView->Free();
  188. }
  189.  
  190. //--------------------------------------------------------------------------------------------------
  191. #pragma segment AOpen
  192.  
  193. pascal TDocument *TDemoTextApplication::DoMakeDocument(CmdNumber )
  194. {
  195.     TTextDocument    *aTextDocument;
  196.  
  197.     aTextDocument = new TTextDocument;
  198.     FailNIL(aTextDocument);
  199.     aTextDocument->ITextDocument();
  200.     return aTextDocument;
  201. }
  202.  
  203. //--------------------------------------------------------------------------------------------------
  204. #if qDebug
  205. #pragma segment ADebug
  206.  
  207. pascal void TDemoTextApplication::IdentifySoftware()
  208. {
  209.     printf("DemoText Source date: 23 April 86; Compiled: %s @ %s\n", __DATE__, __TIME__);
  210.     inherited::IdentifySoftware();
  211. }
  212. #endif
  213.  
  214. //******************************************************************************************
  215. //  T T e x t D o c u m e n t
  216. //******************************************************************************************
  217. //--------------------------------------------------------------------------------------------------
  218. #pragma segment AOpen
  219.  
  220. pascal void TTextDocument::ITextDocument()
  221. {
  222.     fDocText = NULL;
  223.     IDocument(kFileType, kDemoTextSignature, kUsesDataFork, kUsesRsrcFork, ! kDataOpen, ! kRsrcOpen);
  224.  
  225.     fTEView = NULL;
  226.     fStyles = NULL;
  227.     fElements = NULL;
  228.     fDocText = NewPermHandle(0);
  229.     fHasMovie = false;
  230.     FailNIL(fDocText);
  231. }
  232.  
  233. //--------------------------------------------------------------------------------------------------
  234. #pragma segment AClose
  235.  
  236. pascal void TTextDocument::Free()
  237. {
  238.     if (fDocText)
  239.         DisposHandle(fDocText);
  240.     inherited::Free();
  241. }
  242.  
  243. #pragma segment AOpen
  244. pascal void TTextDocument::DoMakeWindows()
  245. {
  246.     Movie                theMovie;
  247.     ComponentResult        theComponentResult;
  248.     OSErr                err;
  249.     SFReply                reply;
  250.     SFTypeList            types;
  251.     Point                where = {100,100};
  252.     
  253.     inherited::DoMakeWindows();
  254.     
  255.     if (fHasMovie) {
  256.         fMovieView->fActualResID = 0;
  257.         fMovieView->fMovieFSSpec = fFSSpec;
  258.         err = OpenMovieFile(&fMovieView->fMovieFSSpec, &fMovieView->fMovieResRefNum,fsRdPerm);
  259.         if (err == fnfErr) {
  260.             types[0] = 'MooV';
  261.             SFGetFile(where,(ConstStr255Param)"\pWhere is your Movie?", nil, 1, types, nil, &reply);
  262.             if (reply.good) {
  263.                 FailOSErr(FSMakeFSSpec(reply.vRefNum, 0, reply.fName, &fMovieView->fMovieFSSpec));
  264.                 FailOSErr(OpenMovieFile(&fMovieView->fMovieFSSpec, &fMovieView->fMovieResRefNum,fsRdPerm));
  265.             }
  266.         }
  267.         FailOSErr(NewMovieFromFile(&theMovie,fMovieView->fMovieResRefNum,&fMovieView->fActualResID,(StringPtr)&fMovieView->fMovieName,newMovieActive,(Boolean*)0));
  268.         FailOSErr(CloseMovieFile(fMovieView->fMovieResRefNum));
  269.         fMovieView->DoSetMovie(theMovie);
  270.         fMovieView->ForceRedraw();
  271.         theComponentResult = MCDoAction(fMovieView->fMC, 8, nil);
  272.         
  273.     }
  274. }
  275.  
  276. //--------------------------------------------------------------------------------------------------
  277. #pragma segment ANonRes
  278.  
  279. pascal void TTextDocument::ChangeBackColor(RGBColor *newColor)
  280. {
  281.     GrafPtr    oldPort;
  282.     TWindow    *itsWindow;
  283.  
  284.  // ??? Is this right?  Should we set the background color even if the view isn't
  285.  //  in a window yet?
  286.     GetPort(&oldPort);
  287.     SetPort((*fTEView->fHTE)->inPort);
  288.     RGBBackColor(newColor);
  289.     itsWindow = fTEView->GetWindow();
  290.     if (itsWindow)
  291.         itsWindow->ForceRedraw();
  292.     SetPort(oldPort);
  293. }
  294.  
  295. //--------------------------------------------------------------------------------------------------
  296. #pragma segment AOpen
  297.  
  298. pascal void TTextDocument::DoInitialState()
  299. {
  300.     fTextSpecs = gDefaultSpecs;
  301. }
  302.  
  303. //--------------------------------------------------------------------------------------------------
  304. #pragma segment AOpen
  305.  
  306. pascal void TTextDocument::DoMakeViews(Boolean forPrinting)
  307. {
  308.     TView                *aView;
  309.     TStdPrintHandler    *aHandler;
  310.     TMovieView            *aMovieView;    //***
  311.             
  312.     if (forPrinting)
  313.     // We're only finder printing--don't need a window, just the view being printed 
  314.         aView = DoCreateViews(this, NULL, kViewRsrcID, &gZeroVPt);
  315.     else
  316.         aView = NewTemplateWindow(kWindowRsrcID, (TDocument*) this);
  317.  
  318.     FailNIL(aView);                                     // ??? Will we have already failed?
  319.     
  320.     aMovieView = (TMovieView*)aView->FindSubView('mvvw');    // create Movie view
  321.     FailNIL(aMovieView);
  322.     fMovieView = aMovieView;
  323.     
  324.     aView = aView->FindSubView('TEVW');
  325.     fTEView = (TTEView*) aView;                            // Must cast because FindSubView returns
  326.                                                         /// TView 
  327.     aHandler = new TStdPrintHandler;
  328.     FailNIL(aHandler);
  329.     aHandler->IStdPrintHandler((TDocument*) this,         // its document
  330.                               (TView*) fTEView,            // its view
  331.                               0,                        // does not have square dots
  332.                               1,                         // horzontal page size is fixed
  333.                               0);                        // vertical page size is variable (could be
  334.                                                         //  set
  335.     // …to true on non-style TE systems)
  336.     aHandler->fMinimalMargins = 0;
  337.     
  338.     gDemoTextApplication->SetTarget((TEvtHandler*)aMovieView);
  339.     gDemoTextApplication->InstallCohandler((TEvtHandler*)aMovieView,true);
  340.     ShowReverted();
  341. }
  342.  
  343. //--------------------------------------------------------------------------------------------------
  344. #pragma segment ASelCommand
  345.  
  346. static SizeDeterminer    sd;                // for shared use by the following functions
  347. static Str255            aName;            // which are used by TTextDocument::DoMenuCommand()
  348. static short            menu;
  349. static short            item;
  350. static TextStyle        newStyle;
  351. static CmdNumber        aCmdNumber;
  352. static TTextDocument    *ttd;            // kludged copy of "this"
  353.  
  354. //--------------------------------------------------------------------------------------------------
  355.  
  356. pascal static TCommand *DoSizeChange(CmdNumber base)
  357. {
  358.     newStyle.tsSize = aCmdNumber - base;
  359.     ttd->fTextSpecs.theTextSize = newStyle.tsSize;
  360.     return ttd->fTEView->DoMakeStyleCommand(&newStyle, cSizeChange, doSize + doToggle);
  361. }
  362.  
  363. //--------------------------------------------------------------------------------------------------
  364.  
  365. pascal static TCommand *DoRelSizeChange(short amount)
  366. {
  367.     newStyle.tsSize = amount;
  368.     ttd->fTextSpecs.theTextSize += amount;
  369.     return ttd->fTEView->DoMakeStyleCommand(&newStyle, cSizeChange, doSize + addSize + doToggle);
  370. }
  371.  
  372. //--------------------------------------------------------------------------------------------------
  373.  
  374. pascal static TCommand *DoFontChange()
  375. {
  376.     GetItem(GetMHandle(menu), item, aName);
  377.     GetFNum(aName, &newStyle.tsFont);
  378.     //ttd->fTextSpecs.theTextFont = aName;
  379.     pstrcpy(ttd->fTextSpecs.theTextFont, aName);        // kludged Pascal string copy
  380.     return ttd->fTEView->DoMakeStyleCommand(&newStyle, cFontChange, doFont + doToggle);
  381. }
  382.  
  383. //--------------------------------------------------------------------------------------------------
  384.  
  385. pascal static TCommand *DoColTextChange()
  386. {
  387.     RGBColor    aColor;
  388.     static Point P4040 = {0x0040, 0x0040};
  389.  
  390.     aColor = ttd->fTextSpecs.theTextColor;
  391.     if (GetColor(P4040, GetPrompt(kColTextPrompt), &aColor, &newStyle.tsColor)) {
  392.         ttd->fTextSpecs.theTextColor = newStyle.tsColor;
  393.         return ttd->fTEView->DoMakeStyleCommand(&newStyle, cColorChange, doColor + doToggle);
  394.     }
  395.     return gNoChanges;
  396. }
  397.  
  398. //--------------------------------------------------------------------------------------------------
  399.  
  400. pascal static void DoColBackChange()
  401. {
  402.     RGBColor    aColor;
  403.     static Point P4040 = {0x0040, 0x0040};
  404.  
  405.     aColor = ttd->fTextSpecs.theBackColor;
  406.     if (GetColor(P4040, GetPrompt(kColBackPrompt), &aColor, &newStyle.tsColor)) {
  407.         ttd->fTextSpecs.theBackColor = newStyle.tsColor;
  408.         ttd->ChangeBackColor(&newStyle.tsColor);
  409.     }
  410. }
  411.  
  412. //--------------------------------------------------------------------------------------------------
  413.  
  414. pascal static TCommand *DoJustChange()
  415. {
  416.     short            newJust;
  417.     TJustCommand    *aJustChange;
  418.  
  419.     switch (aCmdNumber) {
  420.         case cJustLeft:        newJust = teJustLeft;    break;
  421.         case cJustCenter:    newJust = teJustCenter;    break;
  422.         case cJustRight:    newJust = teJustRight;    break;
  423.     }
  424.     aJustChange = new TJustCommand;
  425.     FailNIL(aJustChange);
  426.     aJustChange->IJustCommand(ttd->fTEView, newJust);
  427.     ttd->fTextSpecs.theJustification = newJust;
  428.     return aJustChange;
  429. }
  430.  
  431. //--------------------------------------------------------------------------------------------------
  432.  
  433. pascal static TCommand *DoPlainChange()
  434. {
  435.     newStyle.tsFace = 0;
  436.     ttd->fTextSpecs.theTextFace = 0;
  437.     return ttd->fTEView->DoMakeStyleCommand(&newStyle, cStyleChange, doFace);
  438. }
  439.  
  440. //--------------------------------------------------------------------------------------------------
  441.  
  442. pascal static TCommand *DoStyleChange()
  443. {
  444.     switch (aCmdNumber) {
  445.         case cBold:            newStyle.tsFace = bold;            break;
  446.         case cItalic:        newStyle.tsFace = italic;        break;
  447.         case cUnderline:    newStyle.tsFace = underline;    break;
  448.         case cOutline:        newStyle.tsFace = outline;        break;
  449.         case cShadow:        newStyle.tsFace = shadow;        break;
  450.         case cCondense:        newStyle.tsFace = condense;        break;
  451.         case cExtend:        newStyle.tsFace = extend;        break;
  452.     }
  453.     if (newStyle.tsFace * ttd->fTextSpecs.theTextFace == newStyle.tsFace)
  454.         ttd->fTextSpecs.theTextFace -= newStyle.tsFace;
  455.     else
  456.         ttd->fTextSpecs.theTextFace += newStyle.tsFace;
  457.     return ttd->fTEView->DoMakeStyleCommand(&newStyle, cStyleChange, doFace + doToggle);
  458. }
  459.  
  460. //--------------------------------------------------------------------------------------------------
  461.  
  462. pascal static void InstallChangedDeterminer(VHSelect vhs)
  463. {
  464.     if (sd != ttd->fTEView->fSizeDeterminer[vhs]) {
  465.         ttd->fTEView->fSizeDeterminer[vhs] = sd;
  466.  
  467. // If we changed the horizontal size determiner, we must
  468. // ask the TTEView to recompute the TE rectangles.
  469.         if (vhs == h) {
  470.             if (sd == sizeSuperView)
  471.                 ttd->fTEView->SuperViewChangedSize(&gZeroVPt, 1); // Don't care about deltas
  472.             else if (sd == sizePage)
  473.                 ttd->fTEView->DoPagination();
  474.         }
  475.  
  476.         ttd->fTEView->AdjustSize();
  477.         ttd->fTEView->ForceRedraw();
  478.     }
  479. }
  480.  
  481. //--------------------------------------------------------------------------------------------------
  482.  
  483. pascal static void DoWidthChange()
  484. {
  485.     if (aCmdNumber == cWidthFrame)
  486.         sd = sizeSuperView;
  487.     else if (aCmdNumber == cWidthOnePage)
  488.         sd = sizePage;
  489.     else
  490.         sd = sizeFixed;
  491.  
  492.     InstallChangedDeterminer(h);                    // NB: The following is not undoable in the
  493.                                                     // current version
  494. }
  495.  
  496. //--------------------------------------------------------------------------------------------------
  497.  
  498. pascal static void DoHeightChange()
  499. {
  500.     switch (aCmdNumber) {
  501.         case cHeightFrame:    sd = sizeSuperView;    break;
  502.         case cHeightPages:    sd = sizeFillPages;    break;
  503.         case cHeightText:    sd = sizeVariable;    break;
  504.         case cHeightConst:    sd = sizeFixed;        break;
  505.     }
  506.  
  507.     InstallChangedDeterminer(v);                    // NB: The following is not undoable in the
  508.                                                     // current version
  509. }
  510.  
  511. pascal TCommand *TTextDocument::DoMenuCommand(CmdNumber theCmdNumber)
  512. {
  513.     aCmdNumber = theCmdNumber;        // for use in formerly nested procedures
  514.     ttd = this;                        // ditto
  515.  
  516.     CmdToMenuItem(aCmdNumber, &menu, &item);
  517.  
  518.     if (menu == mFont) {
  519.         return DoFontChange();
  520.     } else {
  521.         if (aCmdNumber >= cSizeMin && aCmdNumber <= cSizeMax)
  522.             return DoSizeChange(cSizeBase);
  523.         else if (aCmdNumber == cSizeGrow)
  524.             return DoRelSizeChange(kRelSizeAmount);
  525.         else if (aCmdNumber == cSizeShrink)
  526.             return DoRelSizeChange( - kRelSizeAmount);
  527.         else if (aCmdNumber >= cJustLeft && aCmdNumber <= cJustRight)
  528.             return DoJustChange();
  529.         else if (aCmdNumber == cPlainText)
  530.             return DoPlainChange();
  531.         else if (aCmdNumber >= cBold && aCmdNumber <= cExtend)
  532.             return DoStyleChange();
  533.         else if (aCmdNumber == cColorText)
  534.             return DoColTextChange();
  535.         else if (aCmdNumber == cColorBackground)
  536.             DoColBackChange();
  537.         else if (aCmdNumber >= cWidthFrame && aCmdNumber <= cWidthOnePage)
  538.             DoWidthChange();
  539.         else if (aCmdNumber >= cHeightFrame && aCmdNumber <= cHeightConst)
  540.             DoHeightChange();
  541.             // ??? Next line has got to change ??????????
  542.         else if (aCmdNumber == cXShowBreaks)
  543.             return fDocPrintHandler->DoMenuCommand(cShowBreaks);
  544.         else if (aCmdNumber == cImportMovie) {
  545.             TImportMovieCommand *aImportMovieCmd = new TImportMovieCommand;
  546.             FailNIL(aImportMovieCmd);
  547.             aImportMovieCmd->IImportMovie(fMovieView,this);
  548.             return (TCommand*)aImportMovieCmd;
  549.             }
  550.         else
  551.             return inherited::DoMenuCommand(aCmdNumber);
  552.     }
  553.     return gNoChanges;
  554. }
  555.  
  556. //--------------------------------------------------------------------------------------------------
  557. #pragma segment AWriteFile
  558.  
  559. pascal void TTextDocument::DoNeedDiskSpace(long  *dataForkBytes, long *rsrcForkBytes)
  560. {
  561.     TEStyleHandle    styles;
  562.     STHandle        elements;
  563.  
  564.     *dataForkBytes += GetHandleSize(fDocText);
  565.  
  566.     *rsrcForkBytes += kPrintInfoSize + kRsrcTypeOverhead + kRsrcOverhead;
  567.  
  568.     if (fTEView->fStyleType == kWithStyle && fTEView->fHTE) {
  569.         fTEView->ExtractStyles(&styles, &elements);
  570.         *rsrcForkBytes += GetHandleSize(Handle(styles)) + kRsrcTypeOverhead +
  571.                          kRsrcOverhead + GetHandleSize(Handle(elements)) + kRsrcTypeOverhead +
  572.                          kRsrcOverhead;
  573.     }
  574.  
  575.     *rsrcForkBytes += sizeof(TextSpecs) + kRsrcTypeOverhead + kRsrcOverhead;
  576.  
  577.     // Get resource file overhead 
  578.     inherited::DoNeedDiskSpace(dataForkBytes, rsrcForkBytes);
  579. }
  580.  
  581. //--------------------------------------------------------------------------------------------------
  582. #pragma segment AReadFile
  583.  
  584. pascal void TTextDocument::DoRead(short aRefNum, Boolean , Boolean )
  585. {
  586.     long            numChars;
  587.     TextSpecsHdl    hTextSpecs;
  588.     Handle            hPrintInfo;
  589.     Handle            mFSSpecHandle;
  590.  
  591.     FailOSErr(GetEOF(aRefNum, &numChars));            // Read in the text 
  592.  
  593.     if (numChars > kUnlimited) {                            // The file may have been created by…
  594.         gApplication->ShowError(0, msgAlert + kFileTooBig);    // …someone else - limit it to 32K!
  595.         numChars = kUnlimited;
  596.     }
  597.  
  598.     SetHandleSize(fDocText, numChars);
  599.     FailMemError();
  600.     FailOSErr(FSRead(aRefNum, &numChars, *fDocText));
  601.  
  602.     fStyles = TEStyleHandle(GetResource(kTextStyleRsrcType, kStylesRsrcID)); // Read in the TEStyleRec
  603.     if (fStyles)
  604.         DetachResource(Handle(fStyles));
  605.  
  606.     fElements =                                            // Read in the STElement array
  607.       STHandle(GetResource(kTextStyleRsrcType, kElementsRsrcID));
  608.     if (fElements)
  609.         DetachResource(Handle(fElements));
  610.  
  611.     hTextSpecs =                                        // Read the text specs resource
  612.       TextSpecsHdl(GetResource(kTextSpecsRsrcType, kTextSpecsRsrcID));
  613.     if (hTextSpecs)
  614.         fTextSpecs = **hTextSpecs;
  615.     else
  616.         DoInitialState();
  617.  
  618.     hPrintInfo =                                        // Read the print info resource
  619.       GetResource(kPrintInfoRsrcType, kPrintInfoRsrcID);
  620.     if (hPrintInfo) {                                    // no print info resources was saved
  621.         if (fPrintInfo == NULL) {
  622.             fPrintInfo = NewPermHandle(kPrintInfoSize);
  623.             FailNIL(fPrintInfo);
  624.         }
  625.         BlockMove(*hPrintInfo, *fPrintInfo, kPrintInfoSize);
  626.     }
  627.     
  628.     mFSSpecHandle = GetResource('mTMP',128);
  629.     if (mFSSpecHandle != nil) {
  630.         fHasMovie = true;
  631.         fFSSpec = *((FSSpecPtr)*mFSSpecHandle);
  632.         DetachResource(mFSSpecHandle);
  633.     }
  634. }
  635.  
  636. //--------------------------------------------------------------------------------------------------
  637. #pragma segment ARes
  638.  
  639. pascal void TTextDocument::DoSetupMenus()
  640. {
  641.     Boolean            hasColor;
  642.     Boolean            hasStyle;
  643.     Boolean            checkPlain;
  644.     Boolean            checkSize;
  645.     Boolean            checkFont;
  646.     Boolean            specChange;
  647.     short            just;
  648.     short            item;
  649.     short            fnt;
  650.     short            c;
  651.     short            aMode;
  652.     Style            aFace;
  653.     SizeDeterminer    sd;
  654.     MenuHandle        aMenuHandle;
  655.     Str255            aName;
  656.     TextStyle        aStyle;
  657.     short            theFont;
  658.     short            startOfSelection, endOfSelection;
  659.     Str255            aStr255;
  660.  
  661.     inherited::DoSetupMenus();
  662.  
  663.     hasColor = gConfiguration.hasColorQD;
  664.     hasStyle = gConfiguration.hasStyleTextEdit;
  665.  
  666. #if qNeedsStyleTextEdit == 0
  667.     if (! hasStyle) {
  668.         //aStr255 = fTextSpecs.theTextFont;
  669.         pstrcpy(aStr255, fTextSpecs.theTextFont);        // kludged Pascal string copy
  670.         GetFNum(aStr255, &aStyle.tsFont);
  671.         aStyle.tsFace = fTextSpecs.theTextFace;
  672.         aStyle.tsSize = fTextSpecs.theTextSize;
  673.         aStyle.tsColor = fTextSpecs.theTextColor;
  674.         checkPlain = aStyle.tsFace = 0;
  675.         checkFont = 1;
  676.     } else
  677. #endif
  678.     {
  679.         startOfSelection = (*fTEView->fHTE)->selStart;
  680.         endOfSelection = (*fTEView->fHTE)->selEnd;
  681.         aMode = doFace;
  682.         checkPlain = fTEView->ContinuousStyle(startOfSelection, endOfSelection, &aMode, &aStyle) &&
  683.                       (aStyle.tsFace == 0);
  684.  
  685.         aMode = doAll;
  686.         aStyle.tsFace = bold | italic | underline | outline | shadow | extend | condense;
  687.         specChange = fTEView->ContinuousStyle(startOfSelection, endOfSelection, &aMode, &aStyle);
  688.         checkFont = ((aMode & doFont) != 0);
  689.     }
  690.  
  691.     aMenuHandle = GetMHandle(mFont);
  692.     // If specs have changed AND EITHER an old-style record OR the font's continuous - Ed.
  693.     specChange = fTEView->fSpecsChanged && ((! hasStyle) || checkFont);
  694.  
  695.     GetFontName(aStyle.tsFont, aName);                    // Get real font number in case tsFont is
  696.     GetFNum(aName, &theFont);                            // …the system or application font.
  697.     for (item=1; item <= CountMItems(aMenuHandle); item++) {
  698.   // There can be more than 31 menu entries with scrolling menus, but trying to enable
  699.   // an item with number > 31 is bad news.  If the menu itself is enabled (which it
  700.   // will be in MacApp if any of the first 31 items is enabled), then the extras
  701.   // will always be enabled.
  702.         if (item <= 31)
  703.             EnableItem(aMenuHandle, item);
  704.         if (checkFont) {
  705.             GetItem(aMenuHandle, item, aName);
  706.             GetFNum(aName, &fnt);
  707.         
  708.             CheckItem(aMenuHandle, item, fnt == theFont);
  709.         }
  710.     }
  711.  
  712.     EnableCheck(cXShowBreaks, 1, ((TStdPrintHandler*)fDocPrintHandler)->fShowBreaks);
  713.  
  714.     sd = fTEView->fSizeDeterminer[h];                    // Enable size determiner related menu items
  715.  
  716.     EnableCheck(cWidthFrame, 1, (sd == sizeSuperView));
  717.     EnableCheck(cWidthOnePage, 1, (sd == sizePage));
  718.     EnableCheck(cWidthView, 1, (sd == sizeFixed));
  719.  
  720.     sd = fTEView->fSizeDeterminer[v];
  721.     EnableCheck(cHeightFrame, 1, (sd == sizeSuperView));
  722.     EnableCheck(cHeightPages, 1, (sd == sizeFillPages));
  723.     EnableCheck(cHeightText, 1, (sd == sizeVariable));
  724.     EnableCheck(cHeightConst, 1, (sd == sizeFixed));
  725.  
  726.     just = fTEView->fJustification;                     // Enable justification related menu items
  727.     EnableCheck(cJustLeft, 1, (just == teJustLeft));
  728.     EnableCheck(cJustCenter, 1, (just == teJustCenter));
  729.     EnableCheck(cJustRight, 1, (just == teJustRight));
  730.  
  731. #if qNeedsHierarchialMenus == 0
  732.     if (gConfiguration.hasHierarchicalMenus)
  733. #endif
  734.     {
  735.         Enable(cStyle, 1);                                //  Enable sub-menus
  736.         Enable(cSize, 1);
  737.         Enable(cFont, 1);
  738.         Enable(cColor, hasColor);
  739.     }
  740.  
  741.     aFace = aStyle.tsFace;
  742.     
  743.     EnableCheck(cPlainText, 1, checkPlain);                // Enable normal Style menu items
  744.     EnableCheck(cBold, 1,      aFace & bold);
  745.     EnableCheck(cItalic, 1,    aFace & italic);
  746.     EnableCheck(cUnderline, 1, aFace & underline);
  747.     EnableCheck(cOutline, 1,   aFace & outline);
  748.     EnableCheck(cShadow, 1,    aFace & shadow);
  749.     EnableCheck(cCondense, 1,  aFace & condense);
  750.     EnableCheck(cExtend, 1,    aFace & extend);
  751.  
  752.     for (c=cSizeMin; c<=cSizeMax; c++) {
  753.         if (hasStyle && ((aMode & doSize) == 0))
  754.             checkSize = 0;
  755.         else
  756.             checkSize = (c - cSizeBase) == aStyle.tsSize;
  757.         EnableCheck(c, 1, checkSize);
  758.         if (fTEView->fSpecsChanged) {
  759.             if ( ((! hasStyle) ||                        // If the record isn't styled, or
  760.                  (aMode & doFont)) &&                    // …it _is_ styled and font is continuous
  761.                RealFont(aStyle.tsFont,c-cSizeBase) )    // …and the size is a real one
  762.                 aFace = outline;                        // …then we outline it
  763.             else
  764.                 aFace = 0;
  765.             SetStyle(c, aFace);
  766.         }
  767.     }
  768.  
  769.     Enable(cSizeGrow, 1);
  770.     Enable(cSizeShrink, 1);
  771.  
  772.     Enable(cColorText, hasColor);
  773.     Enable(cColorBackground, hasColor);
  774.  
  775.     Enable(cImportMovie, true);
  776.     
  777.     fTEView->fSpecsChanged = 0;
  778. }
  779.  
  780. //--------------------------------------------------------------------------------------------------
  781. #pragma segment AWriteFile
  782.  
  783. pascal void TTextDocument::DoWrite(short aRefNum, Boolean )
  784. {
  785.     long            numChars;
  786.     TextSpecsHdl    hTextSpecs;
  787.     Handle            tempHandle;
  788.     TEStyleHandle    styles;
  789.     STHandle        elements;
  790.     FSSpecHandle    mHandle;
  791.     
  792.  
  793.     // Write out the text
  794.     numChars = GetHandleSize(fDocText);
  795.     FailOSErr(FSWrite(aRefNum, &numChars, *fDocText));
  796.  
  797.     if (fTEView->fStyleType == kWithStyle) {
  798.         fTEView->ExtractStyles(&styles, &elements);
  799.         FailOSErr(HandToHand((Handle*)&styles));
  800.         AddResource(Handle(styles), kTextStyleRsrcType, kStylesRsrcID, "\p");
  801.         FailResError();
  802.         FailOSErr(HandToHand((Handle*)&elements));
  803.         AddResource(Handle(elements), kTextStyleRsrcType, kElementsRsrcID, "\p");
  804.         FailResError();
  805.     }
  806.  
  807.     // Write the text specification resource, after converting it to a handle
  808.     hTextSpecs = TextSpecsHdl(NewHandle(sizeof(TextSpecs)));
  809.     FailNIL(hTextSpecs);
  810.     **hTextSpecs = fTextSpecs;
  811.     AddResource(Handle(hTextSpecs), kTextSpecsRsrcType, kTextSpecsRsrcID, "\p");
  812.  
  813.     FailResError();
  814.  
  815.  // Write the print info resource.  Note we can't use MacApp for this because MacApp
  816.  // will write the print info into the data fork.  Note also--we must copy the print
  817.  // info resource to another handle because the Resource Manager will dispose of the
  818.  // resource handles when a resource fork is closed.
  819.     if (fPrintInfo) {                            // Make sure we have one of these guy
  820.         tempHandle = fPrintInfo;
  821.         FailOSErr(HandToHand(&tempHandle));
  822.         AddResource(tempHandle, kPrintInfoRsrcType, kPrintInfoRsrcID, "\p");
  823.         FailResError();
  824.     }
  825. //    Write "Movie" to file
  826.     if ((fMovieView->fMovie) != (Movie)0) {
  827.         mHandle = (FSSpecHandle)NewHandle(sizeof(FSSpec));
  828.         FailNIL((Handle)mHandle);
  829. //        SetResourceSize((Handle)mHandle, sizeof(FSSpec));
  830.         **mHandle = fMovieView->fMovieFSSpec;
  831.         FailOSErr(HandToHand((Handle*)&mHandle));
  832.         AddResource((Handle)mHandle,'mTMP',128,"\pMovie FSSpec");
  833.         FailResError();
  834.     }
  835. }
  836.  
  837. //--------------------------------------------------------------------------------------------------
  838. #pragma segment AClose
  839.  
  840. pascal void TTextDocument::FreeData()
  841. {
  842.     SetHandleSize(fDocText, 0);
  843. }
  844.  
  845. //--------------------------------------------------------------------------------------------------
  846. #pragma segment ARes
  847.  
  848. pascal void TTextDocument::SetSpecStyle()
  849. {
  850.     short        theFont;
  851.     TextStyle    theTS;
  852.     Str255        aStr255;
  853.  
  854.     //aStr255 = fTextSpecs.theTextFont;
  855.     pstrcpy(aStr255, fTextSpecs.theTextFont);    // kludged Pascal string copy
  856.     GetFNum(aStr255, &theFont);
  857.     SetTextStyle(&theTS, theFont, fTextSpecs.theTextFace,
  858.                      fTextSpecs.theTextSize, &fTextSpecs.theTextColor);
  859.     fTEView->SetOneStyle(0, 0, doAll, &theTS, kDontRedraw);
  860. }
  861.  
  862. //--------------------------------------------------------------------------------------------------
  863. #pragma segment AReadFile
  864.  
  865. pascal void TTextDocument::ShowReverted()
  866. {
  867.     RGBColor    aColor;
  868.  
  869.     fTEView->StuffText(fDocText);                        // put in the text
  870.     TESetSelect(0, 0, fTEView->fHTE);
  871.     if (fStyles && fElements)                            // If we're able, stuff style info
  872.         fTEView->StuffStyles(fStyles, fElements);
  873.     else
  874.         SetSpecStyle();
  875. #if qNeedsColorQD == 0
  876.     if (gConfiguration.hasColorQD)
  877. #endif
  878.     {
  879.         aColor = fTextSpecs.theBackColor;
  880.         ChangeBackColor(&aColor);
  881.     }
  882.     fTEView->SetJustification(fTextSpecs.theJustification, kDontRedraw);
  883.     inherited::ShowReverted();
  884. }
  885.  
  886. //--------------------------------------------------------------------------------------------------
  887. #pragma segment AFields
  888.  
  889. pascal void TTextDocument::Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
  890.                             short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink)
  891. {
  892.     (*DoToField)("\pTTextDocument",    NULL, bClass, DoToField_StaticLink);
  893.     (*DoToField)("\pfDocText",            (Ptr) &fDocText, bHandle, DoToField_StaticLink);
  894.     (*DoToField)("\pfTEView",            (Ptr) &fTEView, bObject, DoToField_StaticLink);
  895.     (*DoToField)("\p   fTextSpecs",    NULL, bClass, DoToField_StaticLink);
  896.     (*DoToField)("\p theTextFont",        (Ptr) &fTextSpecs.theTextFont, bString, DoToField_StaticLink);
  897.     (*DoToField)("\p theTextFace",        (Ptr) &fTextSpecs.theTextFace, bStyle, DoToField_StaticLink);
  898.     (*DoToField)("\p theTextSize",        (Ptr) &fTextSpecs.theTextSize, bInteger, DoToField_StaticLink);
  899.     (*DoToField)("\p theTextColor",    (Ptr) &fTextSpecs.theTextColor, bRGBColor, DoToField_StaticLink);
  900.     (*DoToField)("\p theJustification",(Ptr) &fTextSpecs.theJustification, bInteger, DoToField_StaticLink);
  901.     (*DoToField)("\p theBackColor",    (Ptr) &fTextSpecs.theBackColor, bRGBColor, DoToField_StaticLink);
  902.     inherited::Fields(DoToField, DoToField_StaticLink);
  903. }
  904.  
  905. //******************************************************************************************
  906. //  T J u s t C o m m a n d
  907. //******************************************************************************************
  908. //--------------------------------------------------------------------------------------------------
  909. #pragma segment ASelCommand
  910.  
  911. pascal void TJustCommand::IJustCommand(TTEView *itsTEView, short itsNewJust)
  912. {
  913.     ICommand(cJustChange, itsTEView->fDocument, NULL, NULL);
  914.     fTEView = itsTEView;
  915.     fOldJust = itsTEView->fJustification;
  916.     fNewJust = itsNewJust;
  917. }
  918.  
  919. //--------------------------------------------------------------------------------------------------
  920. #pragma segment ADoCommand
  921.  
  922. pascal void TJustCommand::DoIt()
  923. {
  924.     fTEView->SetJustification(fNewJust, kRedraw);
  925. }
  926.  
  927. //--------------------------------------------------------------------------------------------------
  928. #pragma segment ADoCommand
  929.  
  930. pascal void TJustCommand::RedoIt()
  931. {
  932.     DoIt();
  933. }
  934.  
  935. //--------------------------------------------------------------------------------------------------
  936. #pragma segment ADoCommand
  937.  
  938. pascal void TJustCommand::UndoIt()
  939. {
  940.     fTEView->SetJustification(fOldJust, kRedraw);
  941. }
  942.  
  943. //--------------------------------------------------------------------------------------------------
  944. #pragma segment AFields
  945.  
  946. pascal void TJustCommand::Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr,
  947.                           short fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink)
  948. {
  949.     DoToField("\pTJustCommand",    NULL, bClass, DoToField_StaticLink);
  950.     DoToField("\pfTEView",        (Ptr) &fTEView, bObject, DoToField_StaticLink);
  951.     DoToField("\pfOldJust",        (Ptr) &fOldJust, bInteger, DoToField_StaticLink);
  952.     DoToField("\pfNewJust",        (Ptr) &fNewJust, bInteger, DoToField_StaticLink);
  953.     inherited::Fields(DoToField, DoToField_StaticLink);
  954. }
  955.  
  956. // ============================== Movie View ==============================
  957. #pragma segment AOpen
  958. pascal void TMovieView::IRes(TDocument *itsDocument,
  959.                          TView *itsSuperView, Ptr *itsParams)
  960. {
  961.     inherited::IRes(itsDocument, itsSuperView, itsParams);
  962.     fIdleFreq = 1;                                    // so DoSetCursor gets called often    
  963.     this->fMovie = (Movie)0;
  964. }
  965.  
  966. // ------------------------------------------------------------------------
  967. #pragma segment ADraw
  968. pascal void TMovieView::Draw(Rect* /* area */)
  969. {
  970.     ComponentResult    aResult;
  971.     Boolean            aBoolean;
  972.     
  973.     if (fMovie != (Movie)0) {
  974.         if (this->IsShown()) {
  975.             aBoolean = this->Focus();
  976.             aResult = MCSetVisible(fMC, true);
  977.             aResult = MCDraw(fMC, (WindowPtr)this->GetGrafPort());
  978.         }
  979.     }
  980. }
  981.  
  982. // ------------------------------------------------------------------------
  983. #pragma segment ASelCommand
  984. pascal TCommand* TMovieView::DoMouseCommand(Point* /* theMouse */,
  985.                         EventInfo* info, Point* /*hysteresis*/)
  986. {
  987.     ComponentResult    aIsMCEvent;
  988.     
  989.     aIsMCEvent = MCIsPlayerEvent(fMC,info->thePEvent);
  990.     return gNoChanges;
  991. }
  992.  
  993. #pragma segment AOpen
  994. pascal void TMovieView::DoSetMovie(Movie theMovie)
  995. {
  996.     Rect        aRect;
  997.     CWindowPtr    aWindow;
  998.     MovieController    aMC;
  999.     ComponentResult    aCResult;
  1000.     long        aDV;
  1001.     long        aDH;
  1002.     TView        *aView;
  1003.     
  1004.     if (fMovie != (Movie)0)
  1005.         DisposeMovie(fMovie);
  1006.     fMovie = theMovie;
  1007.     GetMovieBox(fMovie, &aRect);
  1008.     OffsetRect(&aRect, -aRect.left, -aRect.top);
  1009.     aRect.right = aRect.right + aRect.right * kMovieControllerHeight / aRect.bottom;
  1010.     aRect.bottom = aRect.bottom + kMovieControllerHeight;
  1011.     OffsetRect(&aRect, kMovieFrameOffset, kMovieFrameOffset);
  1012.     SetMovieBox(fMovie,&aRect);
  1013.     aDH = (long)aRect.right - fSize.h + kMovieFrameOffset * 2;
  1014.     aDV = (long)aRect.bottom - fSize.v + kMovieFrameOffset * 2;
  1015.     aView = this->GetWindow()->FindSubView('SCLR');
  1016.     aView->Locate(0, aView->fLocation.v + aDV, true);
  1017.     aView->Resize(aView->fSize.h, aView->fSize.v - aDV, true);
  1018.     this->Resize((long)aRect.right, (long)aRect.bottom, true);
  1019.     aWindow = (CWindowPtr)this->GetGrafPort();
  1020.     if (this->IsShown()) 
  1021.         this->Focus();
  1022.     SetMovieGWorld(fMovie,(CGrafPtr)aWindow,0);
  1023.     GoToBeginningOfMovie(fMovie);
  1024.     aMC = NewMovieController(fMovie, &aRect, DoTheRightThing);
  1025.     FailNIL(aMC);
  1026.     fMC = aMC;
  1027.     aCResult = MCDraw(fMC, (WindowPtr)aWindow);
  1028.     aCResult = MCSetVisible(fMC, true);
  1029.     
  1030.     
  1031. }
  1032.  
  1033. // ------------------------------------------------------------------------
  1034. #pragma segment ASelCommand
  1035. pascal Boolean TMovieView::DoIdle(IdlePhase phase)
  1036. {
  1037.     Boolean        aBoolean;
  1038.     ComponentResult        aComponentResult;
  1039.     
  1040.     if (phase != idleEnd) {
  1041.         if (this->fMovie != (Movie)0) {
  1042.             if (this->IsShown()) {
  1043.                 aBoolean = this->Focus();
  1044.                 aComponentResult = MCIdle(fMC);
  1045.             }
  1046.         }
  1047.     return (inherited::DoIdle(phase));
  1048.     }
  1049. }
  1050. // ------------------------------------------------------------------------
  1051. #pragma segment AClose
  1052. pascal void TMovieView::Free()
  1053. {
  1054.     gDemoTextApplication->InstallCohandler((TEvtHandler*)this,false);
  1055.  
  1056.     if (fMovie !=  (Movie)0) {
  1057.         CloseComponent(fMC);
  1058.         DisposeMovie(fMovie);
  1059.         fMovie = (Movie)0;
  1060.     }
  1061.     inherited::Free();
  1062. }
  1063.  
  1064. // ------------------------------------------------------------------------
  1065. #pragma segment ASelCommand
  1066. pascal void TImportMovieCommand::IImportMovie(TMovieView *itsView, TTextDocument *itsDocument)
  1067. {
  1068.     this->fMovieView = itsView;
  1069.     this->ICommand(cImportMovie, itsDocument, itsView, 0);
  1070.  
  1071. }
  1072.  
  1073. // ------------------------------------------------------------------------
  1074. #pragma segment ASelCommand
  1075. pascal void TImportMovieCommand::DoIt()
  1076. {
  1077.     OSErr                err;
  1078. //    StandardFileReply    aSFReply;
  1079.     SFReply                reply;
  1080.     SFTypeList            types;
  1081.     FSSpec                movieFSSpec;
  1082.     Movie                theMovie;
  1083.     Point                where = {100,100};
  1084.  
  1085.     types[0] = 'MooV';
  1086. //    StandardGetFile(nil,1,types,&aSFReply);        // Get FSSpec of Movie File by StandardFile package(7.0 and later)
  1087.     SFGetFile(where, "\p", nil, 1, types, nil, &reply);
  1088. //    if (aSFReply.sfGood) {
  1089.     if (reply.good) {
  1090.         FailOSErr(FSMakeFSSpec(reply.vRefNum, 0, reply.fName, &movieFSSpec));
  1091.         fMovieView->fMovieFSSpec = movieFSSpec;
  1092. //        movieFSSpec = aSFReply.sfFile;
  1093.         FailOSErr(err = OpenMovieFile(&movieFSSpec, &fMovieView->fMovieResRefNum,fsRdPerm));
  1094.         fMovieView->fActualResID = 0;
  1095.         FailOSErr(err = NewMovieFromFile(&theMovie,fMovieView->fMovieResRefNum,&fMovieView->fActualResID,(StringPtr)&fMovieView->fMovieName,newMovieActive,(Boolean*)0));
  1096.         FailOSErr(err = CloseMovieFile(fMovieView->fMovieResRefNum));
  1097.         fMovieView->DoSetMovie(theMovie);                // Set Movie
  1098.         fMovieView->ForceRedraw();
  1099.     }
  1100. }